home *** CD-ROM | disk | FTP | other *** search
Wrap
RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMaaaapppp((((3333CCCC++++++++)))) RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMaaaapppp((((3333CCCC++++++++)))) NNNNaaaammmmeeee RWTValHashMap<K,T,H,EQ> - Rogue Wave library class SSSSyyyynnnnooooppppssssiiiissss #include <rw/tvhdict.h> RWTValHashMap<K,T,H,EQ> m; PPPPlllleeeeaaaasssseeee NNNNooootttteeee!!!! IIIIffff yyyyoooouuuu hhhhaaaavvvveeee tttthhhheeee SSSSttttaaaannnnddddaaaarrrrdddd CCCC++++++++ LLLLiiiibbbbrrrraaaarrrryyyy,,,, uuuusssseeee tttthhhheeee iiiinnnntttteeeerrrrffffaaaacccceeee ddddeeeessssccccrrrriiiibbbbeeeedddd hhhheeeerrrreeee.... OOOOtttthhhheeeerrrrwwwwiiiisssseeee,,,, uuuusssseeee tttthhhheeee iiiinnnntttteeeerrrrffffaaaacccceeee ffffoooorrrr RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhDDDDiiiiccccttttiiiioooonnnnaaaarrrryyyy described in Appendix A. DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn This class maintains a collection of keys, each with an associated item of type TTTT. These pairs are stored according to a hash object of type HHHH. HHHH must provide a hash function on elements of type KKKK via a public member uuuunnnnssssiiiiggggnnnneeeedddd lllloooonnnngggg ooooppppeeeerrrraaaattttoooorrrr(((())))((((ccccoooonnnnsssstttt KKKK&&&& xxxx)))) Equivalent keys within the collection will be grouped together based on an equality object of type EEEEQQQQ. EEEEQQQQ must ensure this grouping via public member bbbboooooooollll ooooppppeeeerrrraaaattttoooorrrr(((())))((((ccccoooonnnnsssstttt KKKK&&&& xxxx,,,, ccccoooonnnnsssstttt KKKK&&&& yyyy)))) which should return ttttrrrruuuueeee if xxxx and yyyy are equivalent. RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMaaaapppp<<<<KKKK,,,,TTTT,,,,HHHH,,,,EEEEQQQQ>>>> will not accept a key that compares equal to any key already in the collection. (RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMuuuullllttttiiiiMMMMaaaapppp<<<<KKKK,,,,TTTT,,,,HHHH,,,,EEEEQQQQ>>>> may contain multiple keys that compare equal to each other.) Equality is based on the equality object and not on the ======== operator. PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee Isomorphic RRRReeeellllaaaatttteeeedddd CCCCllllaaaasssssssseeeessss Class RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMuuuullllttttiiiiMMMMaaaapppp<<<<KKKK,,,,TTTT,,,,HHHH,,,,EEEEQQQQ>>>> offers the same interface to a collection that accepts multiple keys that compare equal to each other. Class rrrrwwww____hhhhaaaasssshhhhmmmmaaaapppp<<<<KKKK,,,,TTTT,,,,HHHH,,,,EEEEQQQQ>>>> is the C++-standard compliant collection that serves as the underlying implementation for this collection. PPPPuuuubbbblllliiiicccc TTTTyyyyppppeeeeddddeeeeffffssss typedef rw_hashmap<K,T,H,EQ> container_type; typedef container_type::iterator iterator; typedef container_type::const_iterator const_iterator; typedef container_type::size_type size_type; typedef pair <const K,T> value_type; typedef K key_type; typedef T data_type; typedef pair <const K,T>& reference; typedef pair <const K,T>& const_reference; PPPPaaaaggggeeee 1111 RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMaaaapppp((((3333CCCC++++++++)))) RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMaaaapppp((((3333CCCC++++++++)))) PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrrssss RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMaaaapppp<<<<KKKK,,,,TTTT,,,,HHHH,,,,EEEEQQQQ>>>>(); Constructs an empty map. RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMaaaapppp<<<<KKKK,,,,TTTT,,,,HHHH,,,,EEEEQQQQ>>>>(const rw_hashmap<K,T,H,EQ>& m); Constructs a map by copying all elements of mmmm. RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMaaaapppp<<<<KKKK,,,,TTTT,,,,HHHH,,,,EEEEQQQQ>>>> (const H& h, size_type sz = RWDEFAULT_CAPACITY); Creates an empty hashed map which uses the hash object hhhh and has an initial capacity of sssszzzz. RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMaaaapppp<<<<KKKK,,,,TTTT,,,,HHHH,,,,EEEEQQQQ>>>>(const RWTValHashMap<K,T,H,EQ>& rwm); Copy constructor. RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMaaaapppp<<<<KKKK,,,,TTTT,,,,HHHH,,,,EEEEQQQQ>>>>(const value_type* first, const value_type* last); Constructs a map by copying elements from the array of vvvvaaaalllluuuueeee____ttttyyyyppppeeee pairs pointed to by ffffiiiirrrrsssstttt, up to, but not including, the pair pointed to by llllaaaasssstttt. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr OOOOppppeeeerrrraaaattttoooorrrrssss RWTValHashMap<K,T,H,EQ>& ooooppppeeeerrrraaaattttoooorrrr====(const RWTValHashMap<K,T,H,EQ>& m); RWTValHashMap<K,T,H,EQ>& ooooppppeeeerrrraaaattttoooorrrr====(const rw_hashmap<K,T,H,EQ>& m); Destroys all elements of self and replaces them by copying all associations from mmmm. bool ooooppppeeeerrrraaaattttoooorrrr========(const RWTValHashMap<K,T,H,EQ>& m) const; bool ooooppppeeeerrrraaaattttoooorrrr========(const rw_hashmap<K,T,H,EQ>& m) const; Returns ttttrrrruuuueeee if self compares equal to mmmm, otherwise returns ffffaaaallllsssseeee. Two collections are equal if both have the same number of entries, and iterating through both collections produces, in turn, individual pairs that compare equal to each other. PPPPaaaaggggeeee 2222 RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMaaaapppp((((3333CCCC++++++++)))) RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMaaaapppp((((3333CCCC++++++++)))) T& ooooppppeeeerrrraaaattttoooorrrr[[[[]]]](const K& key); Looks up kkkkeeeeyyyy and returns a reference to its associated item. If the key is not in the dictionary, then it will be added with an associated item provided by the default constructor for type TTTT. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss void aaaappppppppllllyyyy(void (*fn)(const K&, T&, void*),void* d); void aaaappppppppllllyyyy(void (*fn)(const K&,const T&,void*),void* d) const; Applies the user-defined function pointed to by ffffnnnn to every association in the collection. This function must have one of the prototypes: void yourfun(const K& key, T& a, void* d); void yourfun(const K& key, const T& a,void* d); Client data may be passed through parameter dddd. void aaaappppppppllllyyyyTTTTooooKKKKeeeeyyyyAAAAnnnnddddVVVVaaaalllluuuueeee(void (*fn)(const K&, T&,void*),void* d); void aaaappppppppllllyyyyTTTTooooKKKKeeeeyyyyAAAAnnnnddddVVVVaaaalllluuuueeee (void (*fn)(const K&, const T, void*),void* d) const; This is a deprecated version of the aaaappppppppllllyyyy member above. It behaves exactly the same as aaaappppppppllllyyyy.... iterator bbbbeeeeggggiiiinnnn(); const_iterator bbbbeeeeggggiiiinnnn() const; Returns an iterator positioned at the first pair in self. size_type ccccaaaappppaaaacccciiiittttyyyy() const; Returns the number of buckets(slots) available in the underlying hash representation. See rrrreeeessssiiiizzzzeeee below. PPPPaaaaggggeeee 3333 RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMaaaapppp((((3333CCCC++++++++)))) RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMaaaapppp((((3333CCCC++++++++)))) void cccclllleeeeaaaarrrr(); Clears the collection by removing all items from self. Each key and its associated item will have its destructor called. bool ccccoooonnnnttttaaaaiiiinnnnssss(const K& key) const; Returns ttttrrrruuuueeee if there exists a key jjjj in self that compares equal to kkkkeeeeyyyy; otherwise returns ffffaaaallllsssseeee. bool ccccoooonnnnttttaaaaiiiinnnnssss(bool (*fn)(const_reference,void*), void* d) const; Returns ttttrrrruuuueeee if there exists an association aaaa in self such that the expression ((((((((****ffffnnnn))))((((aaaa,,,,dddd)))))))) is ttttrrrruuuueeee, otherwise returns ffffaaaallllsssseeee. ffffnnnn points to a user-defined tester function which must have prototype: bool yourTester(const_reference a, void* d); Client data may be passed through parameter dddd. iterator eeeennnndddd(); const_iterator eeeennnndddd() const; Returns an iterator positioned "just past" the last association in self. size_type eeeennnnttttrrrriiiieeeessss() const; Returns the number of associations in self. float ffffiiiillllllllRRRRaaaattttiiiioooo() const; Returns the ratio eeeennnnttttrrrriiiieeeessss(((())))/ccccaaaappppaaaacccciiiittttyyyy(((()))). PPPPaaaaggggeeee 4444 RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMaaaapppp((((3333CCCC++++++++)))) RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMaaaapppp((((3333CCCC++++++++)))) bool ffffiiiinnnndddd(const K& key, K& r) const; If there exists a key jjjj in self that compares equal to kkkkeeeeyyyy, assigns jjjj to rrrr and returns ttttrrrruuuueeee. Otherwise, returns ffffaaaallllsssseeee and leaves the value of rrrr unchanged. bool ffffiiiinnnndddd(bool (*fn)(const_reference,void*),void* d, pair<K,T>& r) const; If there exists an association aaaa in self such that the expression ((((((((****ffffnnnn))))((((aaaa,,,,dddd)))))))) is ttttrrrruuuueeee, assigns aaaa to rrrr and returns ttttrrrruuuueeee. Otherwise, returns ffffaaaallllsssseeee and leaves the value of kkkk unchanged. ffffnnnn points to a user- defined tester function which must have prototype: bool yourTester(const K& a, void* d); Client data may be passed through parameter dddd. bool ffffiiiinnnnddddVVVVaaaalllluuuueeee(const K& key, T& r) const; If there exists a key jjjj in self that compares equal to kkkkeeeeyyyy, assigns the item associated with jjjj to rrrr and returns ttttrrrruuuueeee. Otherwise, returns ffffaaaallllsssseeee and leaves the value of rrrr unchanged. bool ffffiiiinnnnddddKKKKeeeeyyyyVVVVaaaalllluuuueeee(const K& key, K& kr, T& tr) const; If there exists a key jjjj in self that compares equal to kkkkeeeeyyyy, assigns jjjj to kkkkrrrr, assigns the item associated with jjjj to trrrr,,,, and returns ttttrrrruuuueeee. Otherwise, returns ffffaaaallllsssseeee and leaves the values of kkkkrrrr and ttttrrrr unchanged. bool iiiinnnnsssseeeerrrrtttt(const K& key, const T& a); Adds kkkkeeeeyyyy with associated item aaaa to the collection. Returns ttttrrrruuuueeee if the insertion is successful, otherwise returns ffffaaaallllsssseeee. The function will return ttttrrrruuuueeee unless the collection already holds an association with the equivalent key. PPPPaaaaggggeeee 5555 RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMaaaapppp((((3333CCCC++++++++)))) RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMaaaapppp((((3333CCCC++++++++)))) bool iiiinnnnsssseeeerrrrttttKKKKeeeeyyyyAAAAnnnnddddVVVVaaaalllluuuueeee(const K& key,const T& a); This is a deprecated version of the iiiinnnnsssseeeerrrrtttt member above. It behaves exactly the same as iiiinnnnsssseeeerrrrtttt.... bool iiiissssEEEEmmmmppppttttyyyy() const; Returns ttttrrrruuuueeee if there are no items in the collection, ffffaaaallllsssseeee otherwise. size_type ooooccccccccuuuurrrrrrrreeeennnncccceeeessssOOOOffff(const K& key) const; Returns the number of keys jjjj in self that compare equal to kkkkeeeeyyyy. size_type ooooccccccccuuuurrrrrrrreeeennnncccceeeessssOOOOffff(bool (*fn)(const_reference,void*),void* d) const; Returns the number of associations aaaa in self such that the expression((((((((****ffffnnnn))))((((aaaa,,,,dddd)))))))) is ttttrrrruuuueeee. ffffnnnn points to a user-defined tester function which must have prototype: bool yourTester(const_reference a, void* d); Client data may be passed through parameter dddd. bool rrrreeeemmmmoooovvvveeee(const K& key); Removes the first association with key jjjj in self such that the expression ((((jjjj ======== kkkkeeeeyyyy)))) is ttttrrrruuuueeee and returns ttttrrrruuuueeee. Returns ffffaaaallllsssseeee if there is no such association. bool rrrreeeemmmmoooovvvveeee(bool (*fn)(const_reference,void*), void* d); Removes the first association aaaa in self such that the expression ((((((((****ffffnnnn))))((((aaaa,,,,dddd)))))))) is ttttrrrruuuueeee and returns ttttrrrruuuueeee. Returns ffffaaaallllsssseeee if there is no such element. ffffnnnn points to a user-defined tester function which must have prototype: PPPPaaaaggggeeee 6666 RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMaaaapppp((((3333CCCC++++++++)))) RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMaaaapppp((((3333CCCC++++++++)))) bool yourTester(const_reference a, void* d); Client data may be passed through parameter dddd. size_type rrrreeeemmmmoooovvvveeeeAAAAllllllll(const K& key); Removes all elements jjjj in self that compare equal to kkkkeeeeyyyy. Returns the number of items removed. size_type rrrreeeemmmmoooovvvveeeeAAAAllllllll(bool (*fn)(const_reference,void*), void* d); Removes all associations aaaa in self such that the expression ((((((((****ffffnnnn))))((((aaaa,,,,dddd))))))))is ttttrrrruuuueeee. Returns the number of items removed. ffffnnnn points to a user-defined tester function which must have prototype: bool yourTester(const_reference a, void* d); Client data may be passed through parameter dddd. void rrrreeeessssiiiizzzzeeee(size_type sz); Changes the capacity of self by creating a new hashed map with a capacity of sssszzzz . rrrreeeessssiiiizzzzeeee copies every element of self into the new container and finally swaps the internal representation of the new container with the internal representation of sssseeeellllffff. rw_hashmap<K,T,H,EQ>& ssssttttdddd(); const rw_hashmap<K,T,H,EQ>& ssssttttdddd() const; Returns a reference to the underlying C++-standard collection that serves as the implementation for self. This reference may be used freely, providing access to the C++-standard interface as well as interoperability with other software components that make use of the PPPPaaaaggggeeee 7777 RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMaaaapppp((((3333CCCC++++++++)))) RRRRWWWWTTTTVVVVaaaallllHHHHaaaasssshhhhMMMMaaaapppp((((3333CCCC++++++++)))) C++-standard compliant collections. RRRReeeellllaaaatttteeeedddd GGGGlllloooobbbbaaaallll OOOOppppeeeerrrraaaattttoooorrrrssss RWvostream& ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(RWvostream& strm, const RWTValHashMap<K,T,H,EQ>& coll); RWFile& ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(RWFile& strm, const RWTValHashMap<K,T,H,EQ>& coll); Saves the collection ccccoooollllllll onto the output stream ssssttttrrrrmmmm, or a reference to it if it has already been saved. RWvistream& ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(RWvistream& strm, RWTValHashMap<K,T,H,EQ>& coll); RWFile& ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(RWFile& strm, RWTValHashMap<K,T,H,EQ>& coll); Restores the contents of the collection ccccoooollllllll from the input stream ssssttttrrrrmmmm. RWvistream& ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(RWvistream& strm, RWTValHashMap<K,T,H,EQ>*& p); RWFile& ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(RWFile& strm, RWTValHashMap<K,T,H,EQ>*& p); Looks at the next object on the input stream ssssttttrrrrmmmm and either creates a new collection off the heap and sets pppp to point to it, or sets pppp to point to a previously read instance. If a collection is created off the heap, then you are responsible for deleting it. PPPPaaaaggggeeee 8888